<?php

/**
 *Simple CRUD Code Generator
 *Email:  support@crazedcoders.com
 *Website: http://www.crazedcoders.com/
 *Copyright (C) 2007 CrazedCoders
 *
 *This program is free software: you can redistribute it and/or modify
 *it under the terms of the GNU General Public License as published by
 *the Free Software Foundation, either version 3 of the License, or
 *(at your option) any later version.
 *
 *THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 *SOFTWARE.
 *
 *You should have received a copy of the GNU General Public License
 *along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

# log hits
	$fp = fopen("log.html", "a");
	fputs($fp,date("m.d,  h:i:s").', '.GetHostByName($_SERVER['REMOTE_ADDR']).', Visited<br/>');
	fclose( $fp);
?>

<html>
<head>
   <title>crazedCoders PHP/Cairngorm/Flex2.01 Code Generator</title>
</head>
<style>
body, td, input { font-family:tahoma;font-size:12px;}
input {width:200px}
h1 {font-size:14px; color:#000099; font-weight:bold}
</style>
<body>
<H1 align="center">crazedCoders PHP 5.5.2/Cairngorm 2_2_1/Flex 2.01 Code Generator</H1>
<FORM ACTION="phpDaoGenerator/generateDaos.php" METHOD="GET">
<table align="center" width="720" cellpadding="6">
<tr><td>Enter your default package (i.e. com.crazedcoders.testapp)</td><td><INPUT TYPE="text" NAME="package" value="com.crazedcoders.example"  style="width:100%"></td></tr>
<tr><td>Enter your MySQL server name or IP Address</td><td><INPUT TYPE="text" NAME="dbhost" value="localhost"></td></tr>
<tr><td>Enter your MySQL database name</td><td><INPUT TYPE="text" NAME="dbname" value="test"></td></tr>
<tr><td>Enter your MySQL username (requires full rights to db)</td><td><INPUT TYPE="text" NAME="dbuser" value="test"></td></tr>
<tr><td>Enter your MySQL password</td><td><INPUT TYPE="text" NAME="dbpass" value="test"></td></tr>
<tr><td><input type="hidden" name="dbtype" value="mysql" /></td><td><INPUT TYPE="submit" VALUE="Submit!"> </td></tr>
<tr>
  <td colspan="2"><strong>Notes</strong></td>
</tr>
<tr>
  <td colspan="2"><ul>
    <li>You can get the version of AMFPHP1.9Beta that we used to test this generator <a href="files/amfphp-1.9.beta.20070513.zip">here</a>, for more info click <a href="www.5etdemi.com/blog/archives/2007/01/amfphp-19-beta-2-ridiculously-faster" target="_new">here</a>.</li>
    <li>To speed things up consider installing the <a href="http://www.teslacore.it/wiki/index.php?title=AMFEXT" target="_new">phpamf C extension for AMF</a> by Emanuele Ruffaldi, also available <a href="files/amfext-0.9-bin.zip">here</a>.</li>
    <li>We tested our generator against MySQL version 5.0.x, which you can get <a href="http://dev.mysql.com/downloads/mysql/" target="_new">here</a>.</li>
    <li>We're big fans and avid users of Cairngorm, and the generated flex project comes packaged with the latest version of the Cairngorm library, <a href="http://labs.adobe.com/wiki/index.php/Cairngorm:Cairngorm2.2.1:Download" target="_new">version 2.2.1</a>. You can read more about Cairngorm <a href="http://www.cairngormdocs.org/" target="_new">here</a>.</li>
    <li><em>The provided default values will work, so if you don't feel comfortable exposing your mysql server at this time, just click submit and grab the sample generated zip file! You can get this test database's sql create script here <a href="files/test.zip" target="_new">test.sql</a>!</em></li>
 	<li>Jan8-08 Update: Fixed Issue: Date Validators not working properly</li>
    <li>Jan8-08 Update: Fixed Issue: Dates not saving to mysql, no errors being returned on failed insert</li>
    <li>Jan8-08 Update: Changed how bit/tiny int are handled on update/insert</li> 
    <li>Update: Flexbuilder project files were not properly getting included in the generated zip file. This has been fixed.</li>
    <li>Jan6-08 Update: Fixed Issue: Library path to cairngorm was not set correctly in .actionscriptproperties file</li>
    <li>Jan6-08 Update: Fixed Issue: If column names used reserved words or had "_" the generated DAO code would fail</li>
    <li>Jan6-08 Update: Fixed Issue: Namespace conflicts alleviated by forcing lower case on all provided values</li>
    <li>Jan6-08 Update: Changed wording in instructions</li>
    <li>Jan6-08 Update: Changed default setting in services-config.xml to point to http://localhost/flashservices</li>
  </ul></td>
  </tr>

<tr>
  <td colspan="2"><p><strong>Requirements</strong></p>    </td>
</tr>

<tr>
  <td colspan="2"><p>The code generator runs on our server, which means that in order for this to work, our server will need to be able to connect to your mysql server. That means the IP address or domain name of your mysql server must be publicly accessible. IP Addresses like 192.168.100.1 and server names like momspc won't work. If you are behind a firewall and/or router, you will need to either map port 3306 through to your computer, or place your computer's IP Address in the DMZ of your firewall/router. This of course need only be a temporary measure, once the wizard runs you can quickly seal things up again. Alternatively you could plug your mysql machine directly into your modem, and bypass the firewall/router. If you are using Windows XP, also make sure that your Windows Firewall allows incoming traffic on port 3306. If you need to figure out what your public IP address is and you are on your mysql server, visit a site like this one <a href="http://myipaddress.com/show-my-ip-address/" target="_new">http://myipaddress.com</a> to get that information.</p>
    <p>The username and password you provide must have sufficient rights to query the <a href="http://www.quest-pipelines.com/newsletter-v6/0905_A.htm" target="_new">INFORMATION_SCHEMA</a> of your mysql database, otherwise the generator will fail.</p>
    <p>To use the generate php code you will need to install php and amfphp on your webserver. We've tested this on Apache 2.2 and IIS 6 and have not encountered any issues (although getting php work on IIS 6 was not fun).</p>    </td>
</tr>

<tr>
  <td colspan="2"><strong>Output</strong></td>
</tr>
<tr>
  <td colspan="2"><p>Once the generator is complete you will be provided a link to a zip file and some instructions on what to do next. The zip file has 2 directories amfphp and dbname_flex. The dbname_flex contains your flex project and is the folder that you should point to when import the project into Flexbuilder. The afmphp folder contains a services folder, the contents of which you must copy over into your amfphp/services folder. We do take your db connection information and insert it into the generated php class so that you could technically keep working however you might well need to change it. How to change it is outlined on the generated results page.</p>    </td>
</tr>
<tr>
  <td colspan="2"><strong>Background</strong></td>
</tr>
<tr>
  <td colspan="2">Although we are still adding features, the code generator seems quite stable. It will basically query the schema of a database and determine relationships between all the tables and then build all the php code required to speak to the database. Also, it creates a complete cairngorm structured flex application, with tabbed fully functional views for each non-mapping table, events, commands, and services. It also creates all the project files for Flexbuilder, so you can easily and quickly import the project as is into Flexbuilder, regenerate the html-template folder, compile and run.</td>
</tr>

<tr>
  <td colspan="2"><strong>Features</strong></td>
</tr>
<tr>
  <td colspan="2"><ul>
    <li>GetCount(), GetAllRecords(), GetOneRecord(), Create(), Update(), Delete()</li>
    <li>Support for Numeric, Date, Text and Int fields</li>
    <li>Datepickers, Comboboxes (for lookup tables), checkboxes</li>
    <li>Validators on Numeric and Date fields</li>
    <li>Full AMF3 Remote Object support - passing of strongly typed objects to and from PHP</li>
    <li>Absolutely no styling applied, with the exception of some widths and heights</li>
    <li>Absolutely no use of Delegates as per the true Cairngorm model... we're lazy we just do it all in our Command classes</li>
    <li>Two way binding on all form fields</li>
    <li>Datagrid Views</li>
    <li>Paged/Index Get Record Retrieval Support</li>
  </ul></td>
</tr>

<tr>
  <td colspan="2"><strong>Future Features</strong></td>
</tr>
<tr>
  <td colspan="2"><ul>
    <li>Support for more data types</li>
    <li>Delegate Classes</li>
    <li>Support for Flex 3</li>
    <li>AIR Application Generator</li>
    <li>MSSQL Support (partially complete)</li>
  </ul>    </td>
</tr>
<tr>
  <td colspan="2"><strong>Code  generator source available?</strong></td>
</tr>
<tr>
  <td colspan="2">Sure <a href="http://code.google.com/p/flexamfphpcairnormgenerator/source">http://code.google.com/p/flexamfphpcairnormgenerator/source</a></td>
</tr>
</table>
</FORM>
</body>
</html>